var SPSdk = (function () {
    var SDK_URL = "http://cdn.iwangame.net/js/iwan.js";
    function SPSdk() {
        this.appKey = "";
    }

    var __proto = SPSdk.prototype;
    __proto.login = function (param, callback) {
        console.log("左岸科技登录：" + JSON.stringify(param));
        var m_this = this;
        iwan.init({
            success: function (data) {
                callback && callback({"result": 0,"desc": "OK","spuid": data.user.uid, "nickname": data.user.nickName, "headimgurl":data.user.avator});
            },
            fail: function (data) {
                console.log(data.user);
                callback && callback({ "result": -2, "desc": "login error"});
            }});
    };
    __proto.share = function (param, callback) {
        iwan.share();
    };
    __proto.pay = function (param, callback) {
        var m_this = this;
        console.log("左岸科技支付：" + JSON.stringify(param));
        var data = {goodsid: 1, goodsprice: parseInt(param.data.amount), extra: param.data.orderId, goodscount: 1, goodsname: param.data.goodsName};
        iwan.pay({
            data: data, success: function () {
                callback && callback({"result": "0","desc": "pay success","orderId": param.data.orderid, "amount": param.data.money})
            }, fail: function () {
                callback && callback({"result": "-2", "desc": "pay failed"});
            }
        });
    };
    __proto.init = function (param, callback) {
        console.log("左岸科技初始化：" + JSON.stringify(param));
        var m_this = this;
        LayaCommon.loadScript(SDK_URL, function () {
            m_this.appKey = param.appKey;
            callback && callback({"result": 0, "desc": "OK"});
        }, function () {
            callback({"ret": -1, "msg": "plugin download error"});
        });
    };
    return SPSdk;
})();